package Array;

import com.sun.org.apache.bcel.internal.generic.SWAP;

import java.util.Arrays;

public class Quick {
    public static void quickSort(int [] arr,int start,int end){
        if(start<end){
            int Index=getIndex(arr,start,end);
            quickSort(arr,start,Index-1);
            quickSort(arr,Index+1,end);
        }
    }
    private static int getIndex(int [] arr,int start,int end){
        int i=start;
        int j=end;
        int x=arr[i];
        while (i<j){
            while(i<j&&arr[j]>=x){
                j--;
            }if(i<j){
                arr[i]=arr[j];
                i++;
            }
            while(i<j&&arr[i]<x){
                i++;
            }if(i<j){
                arr[j]=arr[i];
                j--;
            }
        }
        arr[i]=x;
        return i;
    }
}
